package com.arx.character;

import java.util.ArrayList;

import com.arx.common.Common;
import com.arx.common.GlobalConsts;
import com.arx.damages.Damages;
import com.arx.graphics.EERIE_3D;
import com.arx.graphics.EERIE_3DOBJ;
import com.arx.graphics.flyweight.ANIM_HANDLE;
import com.arx.graphics.flyweight.ANIM_USE;
import com.arx.interactive.Interactive;
import com.arx.interactive.InteractiveObject;
import com.arx.item.Equipment;
import com.arx.script.Script;
import com.arx.spell.Spell;
import com.arx.spell.SpellObject;
import com.arx.time.Time;
import com.dalonedrau.d20.Diceroller;

class KEYRING_SLOT {
	private String	slot;
	/**
	 * Creates a new instance of {@link KEYRING_SLOT}.
	 * @param val the value placed in the slot
	 */
	public KEYRING_SLOT(final String val) {
		slot = val;
	}
	public String getSlot() {
		return slot;
	}
	public void setSlot(final String val) {
		slot = val;
	}
}

public class Player extends PlayerStatsBase {
	public static final float	ARX_PLAYER_SKILL_STEALTH_MAX	= 100.0F;
	/** the singleton instance. */
	private static Player		instance;
	/**
	 * Gets the one and only instance of {@link Player}.
	 * @return {@link Player}
	 */
	public static Player getInstance() {
		if (Player.instance == null) {
			Player.instance = new Player();
		}
		return Player.instance;
	}
	/** Hidden constructor. */
	private Player() {}
	/**
	 * Add a key to Keyring.
	 * @param key the key being added
	 */
	public void ARX_KEYRING_Add(final String key) {
		if (Keyring == null) {
			Keyring = new ArrayList<KEYRING_SLOT>();
		}
		Keyring.add(new KEYRING_SLOT(key));
		Keyring_Number++;
	}
	// Sends COMBINE event to "io" for each keyring entry
	// *************************************************************************************
	/**
	 * Sends COMBINE event to "io" for each keyring entry.
	 * @param io the {@link InteractiveObject}
	 */
	public void ARX_KEYRING_Combine(final InteractiveObject io) {
		for (int i = 0; i < Keyring_Number; i++) {
			long scriptReturn = Script.getInstance().SendIOScriptEvent(io,
					GlobalConsts.SM_COMBINE, Keyring.get(i).getSlot());
			if (scriptReturn == GlobalConsts.REFUSE) {
				break;
			}
		}
	}
	/** Init/Reset player Keyring structures. */
	public void ARX_KEYRING_Init() {
		if (Keyring != null && Keyring.size() > 0) {
			for (int i = 0; i < Keyring_Number; i++) {
				Keyring.get(i).setSlot(null);
				Keyring.set(i, null);
			}
			Keyring.clear();
		}
		Keyring_Number = 0;
	}
	//
	public void ARX_PLAYER_BecomesDead() {

	}
	public void ARX_PLAYER_ClickedOnTorch(final InteractiveObject io) {
		/*
		 * if (io == NULL) { return; } if (CURRENT_TORCH == NULL) { if
		 * (io->durability > 0) { if (io->ignition > 0) { if
		 * (ValidDynLight(io->ignit_light)) DynLight[io->ignit_light].exist = 0;
		 * io->ignit_light = -1; if (io->ignit_sound !=
		 * ARX_SOUND_INVALID_RESOURCE) { ARX_SOUND_Stop(io->ignit_sound);
		 * io->ignit_sound = ARX_SOUND_INVALID_RESOURCE; } io->ignition = 0; }
		 * SHOW_TORCH = 1; ARX_SOUND_PlaySFX(SND_TORCH_START);
		 * ARX_SOUND_PlaySFX(SND_TORCH_LOOP, NULL, 1.0F, ARX_SOUND_PLAY_LOOPED);
		 * RemoveFromAllInventories(io); CURRENT_TORCH = io; io->show =
		 * SHOW_FLAG_ON_PLAYER; if (DRAGINTER == io) { DRAGINTER = NULL; } } }
		 * else if (CURRENT_TORCH == io) { ARX_PLAYER_KillTorch(); } else {
		 * ARX_PLAYER_KillTorch(); if (io->durability > 0) { if (io->ignition >
		 * 0) { if (io->ignit_light != -1) { DynLight[io->ignit_light].exist =
		 * 0; io->ignit_light = -1; } if (io->ignit_sound !=
		 * ARX_SOUND_INVALID_RESOURCE) { ARX_SOUND_Stop(io->ignit_sound);
		 * io->ignit_sound = ARX_SOUND_INVALID_RESOURCE; } io->ignition = 0; }
		 * SHOW_TORCH = 1; ARX_SOUND_PlaySFX(SND_TORCH_START);
		 * ARX_SOUND_PlaySFX(SND_TORCH_LOOP, NULL, 1.0F, ARX_SOUND_PLAY_LOOPED);
		 * RemoveFromAllInventories(io); CURRENT_TORCH = io; io->show =
		 * SHOW_FLAG_ON_PLAYER; if (DRAGINTER == io) { DRAGINTER = NULL; } } }
		 */
	}
	public void ARX_PLAYER_ComputePlayerFullStats(final ARXCharacter player) {
		ARX_PLAYER_ComputePlayerStats(player);
		player.setMod_Attribute_Strength(0);
		player.setMod_Attribute_Dexterity(0);
		player.setMod_Attribute_Constitution(0);
		player.setMod_Attribute_Mind(0);
		player.setMod_Skill_Stealth(0);
		player.setMod_Skill_Mecanism(0);
		player.setMod_Skill_Intuition(0);
		player.setMod_Skill_Etheral_Link(0);
		player.setMod_Skill_Object_Knowledge(0);
		player.setMod_Skill_Casting(0);
		player.setMod_Skill_Projectile(0);
		player.setMod_Skill_Close_Combat(0);
		player.setMod_Skill_Defense(0);
		player.setMod_armor_class(0);
		player.setMod_resist_magic(0);
		player.setMod_resist_poison(0);
		player.setMod_Critical_Hit(0);
		player.setMod_damages(0);
		player.setMod_life(0);
		player.setMod_maxlife(0);
		player.setMod_mana(0);
		player.setMod_maxmana(0);

		Equipment.getInstance().ARX_EQUIPMENT_IdentifyAll();

		player.setFull_Weapon_Type(Equipment.getInstance()
				.ARX_EQUIPMENT_GetPlayerWeaponType());

		// the player is always Interactive Object 0
		InteractiveObject io = Interactive.getInstance()
				.getInteractiveObject(0);
		// Check for Equipment Modificators to Attributes
		player.setMod_Attribute_Strength(Equipment.getInstance()
				.ARX_EQUIPMENT_Apply(player, io,
						GlobalConsts.IO_EQUIPITEM_ELEMENT_STRENGTH,
						player.getAttribute_Strength()));
		player.setMod_Attribute_Dexterity(Equipment.getInstance()
				.ARX_EQUIPMENT_Apply(player, io,
						GlobalConsts.IO_EQUIPITEM_ELEMENT_DEXTERITY,
						player.getAttribute_Dexterity()));
		player.setMod_Attribute_Constitution(Equipment.getInstance()
				.ARX_EQUIPMENT_Apply(player, io,
						GlobalConsts.IO_EQUIPITEM_ELEMENT_CONSTITUTION,
						player.getAttribute_Constitution()));
		player.setMod_Attribute_Mind(Equipment.getInstance()
				.ARX_EQUIPMENT_Apply(player, io,
						GlobalConsts.IO_EQUIPITEM_ELEMENT_MIND,
						player.getAttribute_Mind()));
		player.setMod_armor_class(Equipment.getInstance()
				.ARX_EQUIPMENT_Apply(player, io,
						GlobalConsts.IO_EQUIPITEM_ELEMENT_Armor_Class,
						player.getArmor_class()));

		// Check for Equipment Modificators to Skills
		player.setMod_Skill_Stealth(Equipment.getInstance()
				.ARX_EQUIPMENT_Apply(player, io,
						GlobalConsts.IO_EQUIPITEM_ELEMENT_Stealth,
						ARX_PLAYER_Get_Skill_Stealth(player, (byte) 0)));
		player.setMod_Skill_Mecanism(Equipment.getInstance()
				.ARX_EQUIPMENT_Apply(player, io,
						GlobalConsts.IO_EQUIPITEM_ELEMENT_Mecanism,
						ARX_PLAYER_Get_Skill_Mecanism(player, (byte) 0)));
		player.setMod_Skill_Intuition(Equipment.getInstance()
				.ARX_EQUIPMENT_Apply(player, io,
						GlobalConsts.IO_EQUIPITEM_ELEMENT_Intuition,
						ARX_PLAYER_Get_Skill_Intuition(player, (byte) 0)));
		player.setMod_Skill_Etheral_Link(Equipment.getInstance()
				.ARX_EQUIPMENT_Apply(player, io,
						GlobalConsts.IO_EQUIPITEM_ELEMENT_Etheral_Link,
						ARX_PLAYER_Get_Skill_Etheral_Link(player, (byte) 0)));
		player.setMod_Skill_Object_Knowledge(Equipment
				.getInstance()
				.ARX_EQUIPMENT_Apply(player, io,
						GlobalConsts.IO_EQUIPITEM_ELEMENT_Object_Knowledge,
						ARX_PLAYER_Get_Skill_Object_Knowledge(player, (byte) 0)));
		player.setMod_Skill_Casting(Equipment.getInstance()
				.ARX_EQUIPMENT_Apply(player, io,
						GlobalConsts.IO_EQUIPITEM_ELEMENT_Casting,
						ARX_PLAYER_Get_Skill_Casting(player, (byte) 0)));
		player.setMod_Skill_Projectile(Equipment.getInstance()
				.ARX_EQUIPMENT_Apply(player, io,
						GlobalConsts.IO_EQUIPITEM_ELEMENT_Projectile,
						ARX_PLAYER_Get_Skill_Projectile(player, (byte) 0)));
		player.setMod_Skill_Close_Combat(Equipment.getInstance()
				.ARX_EQUIPMENT_Apply(player, io,
						GlobalConsts.IO_EQUIPITEM_ELEMENT_Close_Combat,
						ARX_PLAYER_Get_Skill_Close_Combat(player, (byte) 0)));
		player.setMod_Skill_Defense(Equipment.getInstance()
				.ARX_EQUIPMENT_Apply(player, io,
						GlobalConsts.IO_EQUIPITEM_ELEMENT_Defense,
						ARX_PLAYER_Get_Skill_Defense(player, (byte) 0)));

		player.setMod_resist_magic(Equipment.getInstance()
				.ARX_EQUIPMENT_Apply(player, io,
						GlobalConsts.IO_EQUIPITEM_ELEMENT_Resist_Magic,
						player.getResist_magic()));
		player.setMod_resist_poison(Equipment.getInstance()
				.ARX_EQUIPMENT_Apply(player, io,
						GlobalConsts.IO_EQUIPITEM_ELEMENT_Resist_Poison,
						player.getResist_poison()));
		player.setMod_Critical_Hit(Equipment.getInstance()
				.ARX_EQUIPMENT_Apply(player, io,
						GlobalConsts.IO_EQUIPITEM_ELEMENT_Critical_Hit,
						player.getCritical_Hit()));
		player.setMod_damages(Equipment.getInstance().ARX_EQUIPMENT_Apply(
				player, io, GlobalConsts.IO_EQUIPITEM_ELEMENT_Damages, 0));

		// CHECK OVERFLOW
		float fFullAimTime = Equipment.getInstance().ARX_EQUIPMENT_Apply(
				player, io, GlobalConsts.IO_EQUIPITEM_ELEMENT_AimTime, 0);
		float fCalcHandicap = (player.getFull_Attribute_Dexterity() - 10.f) * 20.f;
		fFullAimTime = Common.getInstance().checkLongValue(fFullAimTime);
		fCalcHandicap = Common.getInstance().checkLongValue(fCalcHandicap);

		// CAST
		player.setFull_AimTime((long) fFullAimTime);

		if (player.getFull_AimTime() <= 0) {
			player.setFull_AimTime(player.getAimTime());
		}

		player.adjustFull_AimTime(-((long) fCalcHandicap));

		if (player.getFull_AimTime() <= 1500) {
			player.setFull_AimTime(1500);
		}

		// / PERCENTILE.....
		player.adjustMod_Attribute_Strength(Equipment.getInstance()
				.ARX_EQUIPMENT_ApplyPercent(
						player,
						io,
						GlobalConsts.IO_EQUIPITEM_ELEMENT_STRENGTH,
						player.getAttribute_Strength()
								+ player.getMod_Attribute_Strength()));
		player.adjustMod_Attribute_Dexterity(Equipment.getInstance()
				.ARX_EQUIPMENT_ApplyPercent(
						player,
						io,
						GlobalConsts.IO_EQUIPITEM_ELEMENT_DEXTERITY,
						player.getAttribute_Dexterity()
								+ player.getMod_Attribute_Dexterity()));
		player.adjustMod_Attribute_Constitution(Equipment.getInstance()
				.ARX_EQUIPMENT_ApplyPercent(
						player,
						io,
						GlobalConsts.IO_EQUIPITEM_ELEMENT_CONSTITUTION,
						player.getAttribute_Constitution()
								+ player.getMod_Attribute_Constitution()));
		player.adjustMod_Attribute_Mind(Equipment.getInstance()
				.ARX_EQUIPMENT_ApplyPercent(
						player,
						io,
						GlobalConsts.IO_EQUIPITEM_ELEMENT_MIND,
						player.getAttribute_Mind()
								+ player.getMod_Attribute_Mind()));
		player.adjustMod_armor_class(Equipment.getInstance()
				.ARX_EQUIPMENT_ApplyPercent(player, io,
						GlobalConsts.IO_EQUIPITEM_ELEMENT_Armor_Class,
						player.getArmor_class() + player.getMod_armor_class()));

		// Check for Equipment Modificators to Skills
		player.adjustMod_Skill_Stealth(Equipment.getInstance()
				.ARX_EQUIPMENT_ApplyPercent(player, io,
						GlobalConsts.IO_EQUIPITEM_ELEMENT_Stealth,
						ARX_PLAYER_Get_Skill_Stealth(player, (byte) 1)));
		player.adjustMod_Skill_Mecanism(Equipment.getInstance()
				.ARX_EQUIPMENT_ApplyPercent(player, io,
						GlobalConsts.IO_EQUIPITEM_ELEMENT_Mecanism,
						ARX_PLAYER_Get_Skill_Mecanism(player, (byte) 1)));
		player.adjustMod_Skill_Intuition(Equipment.getInstance()
				.ARX_EQUIPMENT_ApplyPercent(player, io,
						GlobalConsts.IO_EQUIPITEM_ELEMENT_Intuition,
						ARX_PLAYER_Get_Skill_Intuition(player, (byte) 1)));
		player.adjustMod_Skill_Etheral_Link(Equipment.getInstance()
				.ARX_EQUIPMENT_ApplyPercent(player, io,
						GlobalConsts.IO_EQUIPITEM_ELEMENT_Etheral_Link,
						ARX_PLAYER_Get_Skill_Etheral_Link(player, (byte) 1)));
		player.adjustMod_Skill_Object_Knowledge(Equipment
				.getInstance()
				.ARX_EQUIPMENT_ApplyPercent(player, io,
						GlobalConsts.IO_EQUIPITEM_ELEMENT_Object_Knowledge,
						ARX_PLAYER_Get_Skill_Object_Knowledge(player, (byte) 1)));
		player.adjustMod_Skill_Casting(Equipment.getInstance()
				.ARX_EQUIPMENT_ApplyPercent(player, io,
						GlobalConsts.IO_EQUIPITEM_ELEMENT_Casting,
						ARX_PLAYER_Get_Skill_Casting(player, (byte) 1)));
		player.adjustMod_Skill_Projectile(Equipment.getInstance()
				.ARX_EQUIPMENT_ApplyPercent(player, io,
						GlobalConsts.IO_EQUIPITEM_ELEMENT_Projectile,
						ARX_PLAYER_Get_Skill_Projectile(player, (byte) 1)));
		player.adjustMod_Skill_Close_Combat(Equipment.getInstance()
				.ARX_EQUIPMENT_ApplyPercent(player, io,
						GlobalConsts.IO_EQUIPITEM_ELEMENT_Close_Combat,
						ARX_PLAYER_Get_Skill_Close_Combat(player, (byte) 1)));
		player.adjustMod_Skill_Defense(Equipment.getInstance()
				.ARX_EQUIPMENT_ApplyPercent(player, io,
						GlobalConsts.IO_EQUIPITEM_ELEMENT_Defense,
						ARX_PLAYER_Get_Skill_Defense(player, (byte) 1)));

		player.adjustMod_resist_magic(Equipment
				.getInstance()
				.ARX_EQUIPMENT_ApplyPercent(player, io,
						GlobalConsts.IO_EQUIPITEM_ELEMENT_Resist_Magic,
						player.getResist_magic() + player.getMod_resist_magic()));
		player.adjustMod_resist_poison(Equipment.getInstance()
				.ARX_EQUIPMENT_ApplyPercent(
						player,
						io,
						GlobalConsts.IO_EQUIPITEM_ELEMENT_Resist_Poison,
						player.getResist_poison()
								+ player.getMod_resist_poison()));
		player.adjustMod_Critical_Hit(Equipment
				.getInstance()
				.ARX_EQUIPMENT_ApplyPercent(player, io,
						GlobalConsts.IO_EQUIPITEM_ELEMENT_Critical_Hit,
						player.getCritical_Hit() + player.getMod_Critical_Hit()));
		player.adjustMod_damages(Equipment.getInstance()
				.ARX_EQUIPMENT_ApplyPercent(player, io,
						GlobalConsts.IO_EQUIPITEM_ELEMENT_Damages,
						player.getDamages()));
		// player.Full_AimTime=ARXEquipment.getInstance().ARX_EQUIPMENT_ApplyPercent(
		// io,GlobalConsts.IO_EQUIPITEM_ELEMENT_AimTime,0);

		// Check for Spell Modifications
		// the player is always Interactive Object 0
		io = Interactive.getInstance().getInteractiveObject(0);
		if (io != null) {
			for (short i = 0; i < io.getNb_spells_on(); i++) {
				int n = io.getSpells_onItem(i);
				SpellObject spell = Spell.getInstance().getSpell(n);
				if (spell.exists()) {
					switch (spell.getType()) {
					case GlobalConsts.SPELL_ARMOR:
						player.adjustMod_armor_class(spell
									.getCaster_level());
						break;
					case GlobalConsts.SPELL_LOWER_ARMOR:
						player.adjustMod_armor_class(-spell
									.getCaster_level());
						break;
					case GlobalConsts.SPELL_CURSE:
						player.adjustMod_Attribute_Strength(-spell
									.getCaster_level());
						player.adjustMod_Attribute_Constitution(-spell
									.getCaster_level());
						player.adjustMod_Attribute_Dexterity(-spell
									.getCaster_level());
						player.adjustMod_Attribute_Mind(-spell
									.getCaster_level());
						break;
					case GlobalConsts.SPELL_BLESS:
						player.adjustMod_Attribute_Strength(spell
									.getCaster_level());
						player.adjustMod_Attribute_Dexterity(spell
									.getCaster_level());
						player.adjustMod_Attribute_Constitution(spell
									.getCaster_level());
						player.adjustMod_Attribute_Mind(spell
									.getCaster_level());
						break;
					}
				}
			}
		}

		if (cur_mr == 3) {
			player.adjustMod_Attribute_Strength(1);
			player.adjustMod_Attribute_Mind(10);
			player.adjustMod_Attribute_Constitution(1);
			player.adjustMod_Attribute_Dexterity(10);
			player.adjustMod_Skill_Stealth(5);
			player.adjustMod_Skill_Mecanism(5);
			player.adjustMod_Skill_Intuition(100);
			player.adjustMod_Skill_Etheral_Link(100);
			player.adjustMod_Skill_Object_Knowledge(100);
			player.adjustMod_Skill_Casting(5);
			player.adjustMod_Skill_Projectile(5);
			player.adjustMod_Skill_Close_Combat(5);
			player.adjustMod_Skill_Defense(100);
			player.adjustMod_resist_magic(100);
			player.adjustMod_resist_poison(100);
			player.adjustMod_Critical_Hit(5);
			player.adjustMod_damages(2);
			player.adjustMod_armor_class(100);
			player.setFull_AimTime(100);
		}

		if (sp_max) {
			player.adjustMod_Attribute_Strength(5);
			player.adjustMod_Attribute_Mind(5);
			player.adjustMod_Attribute_Constitution(5);
			player.adjustMod_Attribute_Dexterity(5);
			player.adjustMod_Skill_Stealth(50);
			player.adjustMod_Skill_Mecanism(50);
			player.adjustMod_Skill_Intuition(50);
			player.adjustMod_Skill_Etheral_Link(50);
			player.adjustMod_Skill_Object_Knowledge(50);
			player.adjustMod_Skill_Casting(50);
			player.adjustMod_Skill_Projectile(50);
			player.adjustMod_Skill_Close_Combat(50);
			player.adjustMod_Skill_Defense(50);
			player.adjustMod_resist_magic(10);
			player.adjustMod_resist_poison(10);
			player.adjustMod_Critical_Hit(50);
			player.adjustMod_damages(10);
			player.adjustMod_armor_class(20);
			player.setFull_AimTime(100);
		}

		if (SPECIAL_PNUX > 0) {
			player.adjustMod_Attribute_Strength(Diceroller.getInstance()
					.ARXRnd() * 5.f);
			player.adjustMod_Attribute_Mind(Diceroller.getInstance().ARXRnd() * 5.f);
			player.adjustMod_Attribute_Constitution(Diceroller.getInstance()
					.ARXRnd() * 5.f);
			player.adjustMod_Attribute_Dexterity(Diceroller.getInstance()
					.ARXRnd() * 5.f);
			player.adjustMod_Skill_Stealth(Diceroller.getInstance().ARXRnd() * 20.f);
			player.adjustMod_Skill_Mecanism(Diceroller.getInstance().ARXRnd() * 20.f);
			player.adjustMod_Skill_Intuition(Diceroller.getInstance().ARXRnd() * 20.f);
			player.adjustMod_Skill_Etheral_Link(Diceroller.getInstance()
					.ARXRnd() * 20.f);
			player.adjustMod_Skill_Object_Knowledge(Diceroller.getInstance()
					.ARXRnd() * 20.f);
			player.adjustMod_Skill_Casting(Diceroller.getInstance().ARXRnd() * 20.f);
			player.adjustMod_Skill_Projectile(Diceroller.getInstance().ARXRnd() * 20.f);
			player.adjustMod_Skill_Close_Combat(Diceroller.getInstance()
					.ARXRnd() * 20.f);
			player.adjustMod_Skill_Defense(Diceroller.getInstance().ARXRnd() * 30.f);
			player.adjustMod_resist_magic(Diceroller.getInstance().ARXRnd() * 20.f);
			player.adjustMod_resist_poison(Diceroller.getInstance().ARXRnd() * 20.f);
			player.adjustMod_Critical_Hit(Diceroller.getInstance().ARXRnd() * 20.f);
			player.adjustMod_damages(Diceroller.getInstance().ARXRnd() * 20.f);
			player.adjustMod_armor_class(Diceroller.getInstance().ARXRnd() * 20.f);
		}

		if (cur_rf == 3) {
			player.adjustMod_Attribute_Mind(10);
			player.adjustMod_Skill_Casting(100);
			player.adjustMod_Skill_Etheral_Link(100);
			player.adjustMod_Skill_Object_Knowledge(100);
			player.adjustMod_resist_magic(20);
			player.adjustMod_resist_poison(20);
			player.adjustMod_damages(1);
			player.adjustMod_armor_class(5);
		}

		player.setFull_armor_class(player.getArmor_class()
				+ player.getMod_armor_class());

		if (player.getFull_armor_class() < 0) {
			player.setFull_armor_class(0);
		}

		player.setFull_Attribute_Strength(player.getAttribute_Strength()
				+ player.getMod_Attribute_Strength());

		if (player.getFull_Attribute_Strength() < 0) {
			player.setFull_Attribute_Strength(0);
		}

		player.setFull_Attribute_Mind(player.getAttribute_Mind()
				+ player.getMod_Attribute_Mind());

		if (player.getFull_Attribute_Mind() < 0) {
			player.setFull_Attribute_Mind(0);
		}

		player.setFull_Attribute_Constitution(player
				.getAttribute_Constitution()
				+ player.getMod_Attribute_Constitution());

		if (player.getFull_Attribute_Constitution() < 0) {
			player.setFull_Attribute_Constitution(0);
		}

		player.setFull_Attribute_Dexterity(player.getAttribute_Dexterity()
				+ player.getMod_Attribute_Dexterity());

		if (player.getFull_Attribute_Dexterity() < 0) {
			player.setFull_Attribute_Dexterity(0);
		}

		player.setFull_Skill_Stealth(ARX_PLAYER_Get_Skill_Stealth(player,
				(byte) 1));
		player.setFull_Skill_Mecanism(ARX_PLAYER_Get_Skill_Mecanism(player,
				(byte) 1));
		player.setFull_Skill_Intuition(ARX_PLAYER_Get_Skill_Intuition(player,
				(byte) 1));
		player.setFull_Skill_Etheral_Link(ARX_PLAYER_Get_Skill_Etheral_Link(
				player, (byte) 1));
		player.setFull_Skill_Object_Knowledge(ARX_PLAYER_Get_Skill_Object_Knowledge(
				player, (byte) 1));
		player.setFull_Skill_Casting(ARX_PLAYER_Get_Skill_Casting(player,
				(byte) 1));
		player.setFull_Skill_Projectile(ARX_PLAYER_Get_Skill_Projectile(player,
				(byte) 1));
		player.setFull_Skill_Close_Combat(ARX_PLAYER_Get_Skill_Close_Combat(
				player, (byte) 1));
		player.setFull_Skill_Defense(ARX_PLAYER_Get_Skill_Defense(player,
				(byte) 1));

		player.setFull_resist_magic(player.getResist_magic()
				+ player.getMod_resist_magic());

		if (player.getFull_resist_magic() < 0) {
			player.setFull_resist_magic(0);
		}

		player.setFull_resist_poison(player.getResist_poison()
				+ player.getMod_resist_poison());

		if (player.getFull_resist_poison() < 0) {
			player.setFull_resist_poison(0);
		}

		player.setFull_Critical_Hit(player.getCritical_Hit()
				+ player.getMod_Critical_Hit());

		if (player.getFull_Critical_Hit() < 0) {
			player.setFull_Critical_Hit(0);
		}

		player.setFull_damages(player.getDamages() + player.getMod_damages()
				+ player.getFull_Skill_Close_Combat() * GlobalConsts.DIV10);

		if (player.getFull_damages() < 1) {
			player.setFull_damages(1);
		}

		player.setFull_life(player.getLife());
		player.setFull_mana(player.getMana());
		player.setFull_maxlife(player.getFull_Attribute_Constitution()
				* (player.getLevel() + 2) + player.getMod_maxlife());
		player.setLife(Math.min(player.getLife(), player.getFull_maxlife()));
		player.setFull_maxmana(player.getFull_Attribute_Mind()
				* (player.getLevel() + 1) + player.getMod_maxmana());
		player.setMana(Math.min(player.getMana(), player.getFull_maxmana()));
	}
	// FUNCTION/RESULT:
	// updates some player stats depending on time:
	// .life/mana recovery
	// .poison evolution
	// .hunger check
	// .invisibility
	// *************************************************************************************
	public void ARX_PLAYER_FrameCheck(final ARXCharacter player,
			final float Framedelay) {
		// ARX_PLAYER_QuickGeneration();
		if (Framedelay > 0) {
			Interactive.getInstance().UpdateIOInvisibility(
					Interactive.getInstance()
							.getInteractiveObject(0));
			// Natural LIFE recovery
			float inc = 0.00008f
					* Framedelay
					* (player.getFull_Attribute_Constitution()
							+ player.getFull_Attribute_Strength()
							* GlobalConsts.DIV2 + player
							.getFull_Skill_Defense())
					* GlobalConsts.DIV50;

			if (player.getLife() > 0.f) {
				float inc_hunger = 0.00008f
						* Framedelay
						* (player.getFull_Attribute_Constitution() + player
								.getFull_Attribute_Strength()
								* GlobalConsts.DIV2)
						* GlobalConsts.DIV50;

				// Check for player hungry sample playing
				if (player.getHunger() > 10.f && player.getHunger()
						- inc_hunger <= 10.f
						|| player.getHunger() < 10.f && Time.getInstance()
								.getARXTime() > LastHungerSample + 180000) {
					LastHungerSample = Time.getInstance().ARXTimeUL();

					if (!BLOCK_PLAYER_CONTROLS) {
						boolean bOk = true;
						/*
						 * for (short i = 0; i < GlobalConsts.MAX_ASPEECH; i++)
						 * { if (aspeech[i].exist && (aspeech[i].io ==
						 * inter.iobj[0])) { bOk = false; } } if (bOk) {
						 * ARX_SPEECH_AddSpeech(inter.iobj[0],
						 * "[Player_Off_Hungry]", PARAM_LOCALISED,
						 * ANIM_TALK_NEUTRAL, ARX_SPEECH_FLAG_NOTEXT); }
						 */
					}
				}
				player.setHunger(player.getHunger() - inc_hunger * .5f);

				if (player.getHunger() < -10.f) {
					player.setHunger(-10.f);
				}

				if (!BLOCK_PLAYER_CONTROLS) {
					if (player.getHunger() < 0.f) {
						player.setLife(player.getLife() - inc
								* GlobalConsts.DIV2);
					} else {
						player.setLife(player.getLife() + inc);
					}
				}

				// Natural MANA recovery
				float manaRec = player.getMana();
				manaRec += 0.00008f
						* Framedelay
						* (player.getFull_Attribute_Mind() + player
								.getFull_Skill_Etheral_Link()) * 10
						* GlobalConsts.DIV100; // _framedelay*DIV1000;
				player.setMana(manaRec);

				if (player.getMana() > player.getFull_maxmana()) {
					player.setMana(player.getFull_maxmana());
				}
			}

			// float
			// pmaxlife=(float)player.Full_Attribute_Constitution*(float)(player.level+2);
			if (player.getLife() > player.getFull_maxlife()) {
				player.setLife(player.getFull_maxlife());
			}

			// Now Checks Poison Progression
			if (!BLOCK_PLAYER_CONTROLS) {
				if (player.getPoison() > 0.f) {
					float cp = player.getPoison();
					cp *= GlobalConsts.DIV2 * Framedelay * GlobalConsts.DIV1000
							* GlobalConsts.DIV2;
					float faster = 10.f - player.getPoison();

					if (faster < 0.f) {
						faster = 0.f;
					}

					if (Diceroller.getInstance().ARXRnd() * 100.f > player
							.getResist_poison() + faster) {
						float dmg = cp * GlobalConsts.DIV3;

						if (player.getLife() - dmg <= 0.f) {
							Damages.getInstance().ARX_DAMAGES_DamagePlayer(dmg,
									GlobalConsts.DAMAGE_TYPE_POISON,
									-1, null);
						} else {
							player.setLife(player.getLevel() - dmg);
						}
						player.setPoison(player.getPoison() - cp
								* GlobalConsts.DIV10);
					} else {
						player.setPoison(player.getPoison() - cp);
					}
				}
			}

			if (player.getPoison() < 0.1f) {
				player.setPoison(0f);
			}
		}
	}
	/**
	 * Fills "pos" with player "front pos" for sound purpose.
	 * @param player the {@link ARXCharacter}
	 * @param pos
	 */
	public void ARX_PLAYER_FrontPos(final ARXCharacter player,
			final EERIE_3D pos) {
		/*
		 * pos->x = player.pos.x - EEsin(DEG2RAD(MAKEANGLE(player.angle.b))) *
		 * 100.f; pos->y = player.pos.y + 100.f; //-100.f; pos->z = player.pos.z
		 * + EEcos(DEG2RAD(MAKEANGLE(player.angle.b))) * 100.f;
		 */
	}
	// *************************************************************************************
	// public float ARX_PLAYER_Get_Skill_Casting(final ARXCHARACTER player, byte
	// type)
	// -------------------------------------------------------------------------------------
	// FUNCTION/RESULT:
	// Returns player Casting Skill level (Plain (type==0) or Modified
	// (type==1))
	// *************************************************************************************
	public float ARX_PLAYER_Get_Skill_Casting(final ARXCharacter player,
			final byte type) {
		float val = 0f;
		if (USE_NEW_SKILLS) {
			if (type == 0) {
				val = player.getSkill_Casting() + player.getAttribute_Mind()
						* 2.f;
			} else {
				val = player.getSkill_Casting() + player.getMod_Skill_Casting()
						+ player.getFull_Attribute_Mind() * 2.f;
			}
		} else {
			if (type == 0) {
				val = player.getSkill_Casting() + player.getAttribute_Mind()
						* 2.f;
			} else {
				val = player.getSkill_Casting() + player.getMod_Skill_Casting()
						+ player.getFull_Attribute_Mind() * 2.f;
			}
		}
		return val;
	}
	// *************************************************************************************
	// public float ARX_PLAYER_Get_Skill_Close_Combat(final ARXCHARACTER player,
	// byte type)
	// -------------------------------------------------------------------------------------
	// FUNCTION/RESULT:
	// Returns player Close Combat Skill level (Plain (type==0) or Modified
	// (type==1))
	// *************************************************************************************
	public float ARX_PLAYER_Get_Skill_Close_Combat(final ARXCharacter player,
			final byte type) {
		float val = 0f;
		if (USE_NEW_SKILLS) {
			if (type == 0) {
				val = player.getSkill_Close_Combat()
						+ player.getAttribute_Dexterity() + player
								.getAttribute_Strength() * 2;
			} else {
				val = player.getSkill_Close_Combat()
						+ player.getMod_Skill_Close_Combat()
						+ player.getFull_Attribute_Dexterity() + player
								.getFull_Attribute_Strength() * 2;
			}
		} else {
			if (type == 0) {
				val = player.getSkill_Close_Combat()
						+ player.getAttribute_Dexterity() + player
								.getAttribute_Strength();
			} else {
				val = player.getSkill_Close_Combat()
						+ player.getMod_Skill_Close_Combat()
						+ player.getFull_Attribute_Dexterity() + player
								.getFull_Attribute_Strength();
			}
		}
		return val;
	}
	// *************************************************************************************
	// public float ARX_PLAYER_Get_Skill_Defense(final ARXCHARACTER player, byte
	// type)
	// -------------------------------------------------------------------------------------
	// FUNCTION/RESULT:
	// Returns player Defense Skill level (Plain (type==0) or Modified
	// (type==1))
	// *************************************************************************************
	/**
	 * Returns player Defense Skill level (Plain (type==0) or Modified
	 * (type==1)).
	 * @param player
	 * @param type
	 * @return
	 */
	public float ARX_PLAYER_Get_Skill_Defense(final ARXCharacter player,
			final byte type) {
		float val = 0f;
		if (USE_NEW_SKILLS) {
			if (type == 0) {
				val = player.getSkill_Defense()
						+ player.getAttribute_Constitution() * 3;
			} else {
				val = player.getSkill_Defense() + player.getMod_Skill_Defense()
						+ player.getFull_Attribute_Constitution() * 3;
			}
		} else {
			if (type == 0) {
				val = player.getSkill_Defense()
						+ player.getAttribute_Dexterity() + player
								.getAttribute_Constitution();
			} else {
				val = player.getSkill_Defense()
						+ player.getMod_Skill_Defense()
						+ player.getFull_Attribute_Dexterity() + player
								.getFull_Attribute_Constitution();
			}
		}
		return val;
	}
	// *************************************************************************************
	// public float ARX_PLAYER_Get_Skill_Etheral_Link(final ARXCHARACTER player,
	// byte type)
	// -------------------------------------------------------------------------------------
	// FUNCTION/RESULT:
	// Returns player Etheral Link Skill level (Plain (type==0) or Modified
	// (type==1))
	// *************************************************************************************
	public float ARX_PLAYER_Get_Skill_Etheral_Link(final ARXCharacter player,
			final byte type) {
		float val = 0f;
		if (USE_NEW_SKILLS) {
			if (type == 0) {
				val = player.getSkill_Etheral_Link()
						+ player.getAttribute_Mind() * 2.f;
			} else {
				val = player.getSkill_Etheral_Link()
						+ player.getMod_Skill_Etheral_Link()
						+ player.getFull_Attribute_Mind() * 2.f;
			}
		} else {
			if (type == 0) {
				val = player.getSkill_Etheral_Link()
						+ player.getAttribute_Mind() * 2.f;
			} else {

				val = player.getSkill_Etheral_Link()
						+ player.getMod_Skill_Etheral_Link()
						+ player.getFull_Attribute_Mind() * 2.f;
			}
		}
		return val;
	}
	// *************************************************************************************
	// public float ARX_PLAYER_Get_Skill_Intuition(final ARXCHARACTER player,
	// byte type)
	// -------------------------------------------------------------------------------------
	// FUNCTION/RESULT:
	// Returns player Intuition Skill level (Plain (type==0) or Modified
	// (type==1))
	// *************************************************************************************
	public float ARX_PLAYER_Get_Skill_Intuition(final ARXCharacter player,
			final byte type) {
		float val = 0f;
		if (USE_NEW_SKILLS) {
			if (type == 0) {
				val = player.getSkill_Intuition()
						+ player.getAttribute_Mind() * 2;
			} else {
				val = player.getSkill_Intuition()
						+ player.getMod_Skill_Intuition()
						+ player.getFull_Attribute_Mind() * 2;
			}
		} else {
			if (type == 0) {
				val = player.getSkill_Intuition()
						+ player.getAttribute_Dexterity() + player
								.getAttribute_Mind();
			} else {
				val = player.getSkill_Intuition()
						+ player.getMod_Skill_Intuition()
						+ player.getFull_Attribute_Dexterity() + player
								.getFull_Attribute_Mind();
			}
		}
		return val;
	}
	// Returns player Mecanism Skill level (Plain (type==0) or Modified
	// (type==1))
	// *************************************************************************************
	public float ARX_PLAYER_Get_Skill_Mecanism(final ARXCharacter player,
			final byte type) {
		float val = 0f;
		if (USE_NEW_SKILLS) {
			if (type == 0) {
				val = player.getSkill_Mecanism()
						+ player.getAttribute_Dexterity() + player
								.getAttribute_Mind();
			} else {
				val = player.getSkill_Mecanism()
						+ player.getMod_Skill_Mecanism()
						+ player.getFull_Attribute_Dexterity() + player
								.getFull_Attribute_Mind();
			}
		} else {
			if (type == 0) {
				val = player.getSkill_Mecanism()
						+ player.getAttribute_Dexterity() + player
								.getAttribute_Mind();
			} else {
				val = player.getSkill_Mecanism()
						+ player.getMod_Skill_Mecanism()
						+ player.getFull_Attribute_Dexterity() + player
								.getFull_Attribute_Mind();
			}
		}
		return val;
	}
	// *************************************************************************************
	// public float ARX_PLAYER_Get_Skill_Object_Knowledge(final ARXCHARACTER
	// player, byte type)
	// -------------------------------------------------------------------------------------
	// FUNCTION/RESULT:
	// Returns player Object Knowledge Skill level (Plain (type==0) or Modified
	// (type==1))
	// *************************************************************************************
	public float ARX_PLAYER_Get_Skill_Object_Knowledge(
			final ARXCharacter player, final byte type) {
		float val = 0f;
		if (USE_NEW_SKILLS) {
			if (type == 0) {
				val = player.getSkill_Object_Knowledge()
						+ (player.getAttribute_Mind() * 3.f
								+ player.getAttribute_Dexterity() + player
									.getAttribute_Strength())
						* GlobalConsts.DIV2;
			} else {

				val = player.getSkill_Object_Knowledge()
						+ player.getMod_Skill_Object_Knowledge()
						+ (player.getAttribute_Mind() * 3.f
								+ player.getAttribute_Dexterity() + player
									.getAttribute_Strength())
						* GlobalConsts.DIV2;
			}
		} else {
			if (type == 0) {
				val = player.getSkill_Object_Knowledge()
						+ player.getAttribute_Mind() * 2.f;
			} else {

				val = player.getSkill_Object_Knowledge()
						+ player.getMod_Skill_Object_Knowledge()
						+ player.getFull_Attribute_Mind() * 2.f;
			}
		}
		return val;
	}
	// *************************************************************************************
	// public float ARX_PLAYER_Get_Skill_Projectile(final ARXCHARACTER player,
	// byte type)
	// -------------------------------------------------------------------------------------
	// FUNCTION/RESULT:
	// Returns player Projectile Skill level (Plain (type==0) or Modified
	// (type==1))
	// *************************************************************************************
	public float ARX_PLAYER_Get_Skill_Projectile(final ARXCharacter player,
			final byte type) {
		float val = 0f;
		if (USE_NEW_SKILLS) {
			if (type == 0) {
				val = player.getSkill_Projectile()
						+ player.getAttribute_Dexterity() * 2.f
						+ player.getAttribute_Strength();
			} else {
				val = player.getSkill_Projectile()
						+ player.getMod_Skill_Projectile()
						+ player.getAttribute_Dexterity() * 2.f
						+ player.getAttribute_Strength();
			}
		} else {
			if (type == 0) {
				val = player.getSkill_Projectile()
						+ player.getAttribute_Dexterity() * 2.f;
			} else {

				val = player.getSkill_Projectile()
						+ player.getMod_Skill_Projectile()
						+ player.getFull_Attribute_Dexterity() * 2.f;
			}
		}
		return val;
	}
	/**
	 * Returns player Stealth Skill level (Plain (type==0) or Modified
	 * (type==1)).
	 * @param player the {@link ARXCharacter}
	 * @param type the type
	 * @return float
	 */
	public float ARX_PLAYER_Get_Skill_Stealth(final ARXCharacter player,
			final byte type) {
		float val = 0f;
		if (USE_NEW_SKILLS) {
			if (type == 0) {
				val = player.getSkill_Stealth()
						+ player.getAttribute_Dexterity() * 2;
			} else {
				val = player.getSkill_Stealth() + player.getMod_Skill_Stealth()
						+ player.getFull_Attribute_Dexterity() * 2;
			}
		} else {
			if (type == 0) {
				val = player.getSkill_Stealth()
						+ player.getAttribute_Dexterity() + player
								.getAttribute_Mind();
			} else {
				val = player.getSkill_Stealth()
						+ player.getMod_Skill_Stealth()
						+ player.getFull_Attribute_Dexterity() + player
								.getFull_Attribute_Mind();
			}
		}
		return val;
	}
	public boolean ARX_PLAYER_IsInFightMode() {
		boolean isIn = false;
		if (player.hasInterfaceFlag(GlobalConsts.INTER_COMBATMODE)) {
			isIn = true;
		}
		if (!isIn) { // the player isn't in fight mode yet
			// the player is ALWAYS Interactive Object 0
			InteractiveObject io0 = Interactive.getInstance()
					.getInteractiveObject(0);
			// the player is in an animation
			if (io0 != null && io0.getAnimLayer(1) != null
					&& io0.getAnimLayer(1).getCur_anim() != null) {
				ANIM_USE ause1 = io0.getAnimLayer(1);
				ANIM_HANDLE[] alist = io0.getAnims();
				ANIM_HANDLE curr = ause1.getCur_anim();
				// if the animation shows the player wielding a weapon
				// the player is obviously in fight mode
				if (curr == alist[GlobalConsts.ANIM_BARE_READY]
						|| curr == alist[GlobalConsts.ANIM_BARE_UNREADY]
						|| curr == alist[GlobalConsts.ANIM_DAGGER_READY_PART_1]
						|| curr == alist[GlobalConsts.ANIM_DAGGER_READY_PART_2]
						|| curr == alist[GlobalConsts.ANIM_DAGGER_UNREADY_PART_1]
						|| curr == alist[GlobalConsts.ANIM_DAGGER_UNREADY_PART_2]
						|| curr == alist[GlobalConsts.ANIM_1H_READY_PART_1]
						|| curr == alist[GlobalConsts.ANIM_1H_READY_PART_2]
						|| curr == alist[GlobalConsts.ANIM_1H_UNREADY_PART_1]
						|| curr == alist[GlobalConsts.ANIM_1H_UNREADY_PART_2]
						|| curr == alist[GlobalConsts.ANIM_2H_READY_PART_1]
						|| curr == alist[GlobalConsts.ANIM_2H_READY_PART_2]
						|| curr == alist[GlobalConsts.ANIM_2H_UNREADY_PART_1]
						|| curr == alist[GlobalConsts.ANIM_2H_UNREADY_PART_2]
						|| curr == alist[GlobalConsts.ANIM_MISSILE_READY_PART_1]
						|| curr == alist[GlobalConsts.ANIM_MISSILE_READY_PART_2]
						|| curr == alist[GlobalConsts.ANIM_MISSILE_UNREADY_PART_1]
						|| curr == alist[GlobalConsts.ANIM_MISSILE_UNREADY_PART_2]) {
					isIn = true;
				}
			}
		}
		return isIn;
	}
	public void ARX_PLAYER_KillTorch() {
		/*
		 * CURRENT_TORCH->show = SHOW_FLAG_IN_SCENE;
		 * ARX_SOUND_PlaySFX(SND_TORCH_END); ARX_SOUND_Stop(SND_TORCH_LOOP); if
		 * (CanBePutInInventory(CURRENT_TORCH)) { if (CURRENT_TORCH)
		 * CURRENT_TORCH->show = SHOW_FLAG_IN_INVENTORY; } else {
		 * PutInFrontOfPlayer(CURRENT_TORCH, 1); } CURRENT_TORCH = NULL;
		 * SHOW_TORCH = 0; DynLight[0].exist = 0;
		 */
	}
	
	public void ARX_PLAYER_MakeAverageHero(final ARXCharacter player) {
		ARX_PLAYER_MakeFreshHero(player);

		player.adjustAttribute_Strength(4);
		player.adjustAttribute_Mind(4);
		player.adjustAttribute_Dexterity(4);
		player.adjustAttribute_Constitution(4);

		player.adjustSkill_Stealth(2);
		player.adjustSkill_Mecanism(2);
		player.adjustSkill_Intuition(2);
		player.adjustSkill_Etheral_Link(2);
		player.adjustSkill_Object_Knowledge(2);
		player.adjustSkill_Casting(2);
		player.adjustSkill_Projectile(2);
		player.adjustSkill_Close_Combat(2);
		player.adjustSkill_Defense(2);

		player.setAttribute_Redistribute((short) 0);
		player.setSkill_Redistribute((short) 0);

		player.setLevel((short) 0);
		player.setXp(0);
		player.setHunger(100.f);

		ARX_PLAYER_ComputePlayerStats(player);
	}
	/**
	 * Creates a "Fresh" hero.
	 * @param player
	 */
	public void ARX_PLAYER_MakeFreshHero(final ARXCharacter player) {
		player.setAttribute_Strength(6);
		player.setAttribute_Mind(6);
		player.setAttribute_Dexterity(6);
		player.setAttribute_Constitution(6);

		player.setSkill_Stealth(0);
		player.setSkill_Mecanism(0);
		player.setSkill_Intuition(0);
		player.setSkill_Etheral_Link(0);
		player.setSkill_Object_Knowledge(0);
		player.setSkill_Casting(0);
		player.setSkill_Projectile(0);
		player.setSkill_Close_Combat(0);
		player.setSkill_Defense(0);

		player.setOld_Skill_Stealth(player.getSkill_Stealth());
		player.setOld_Skill_Mecanism(player.getSkill_Mecanism());
		player.setOld_Skill_Intuition(player.getSkill_Intuition());
		player.setOld_Skill_Etheral_Link(player.getSkill_Etheral_Link());
		player.setOld_Skill_Object_Knowledge(player.getSkill_Object_Knowledge());
		player.setOld_Skill_Casting(player.getSkill_Casting());
		player.setOld_Skill_Projectile(player.getSkill_Projectile());
		player.setOld_Skill_Close_Combat(player.getSkill_Close_Combat());
		player.setOld_Skill_Defense(player.getSkill_Defense());

		player.setAttribute_Redistribute((short) 16);
		player.setSkill_Redistribute((short) 18);

		player.setLevel((short) 0);
		player.setXp(0);
		player.setPoison(0.f);
		player.setHunger(100.f);
		player.setSkin((short) 0);
		player.setBag((short) 1);

		ARX_PLAYER_ComputePlayerStats(player);
		player.setRune_flags(0);
		if (player.getSpellToMemorize() != null) {
			player.getSpellToMemorize().setbSpell(false);
		}
	}
	/**
	 * Creates a "POWERFULL" hero.
	 * @param player
	 */
	public void ARX_PLAYER_MakePowerfullHero(final ARXCharacter player) {
		player.setAttribute_Strength(18);
		player.setAttribute_Mind(18);
		player.setAttribute_Dexterity(18);
		player.setAttribute_Constitution(18);

		player.setSkill_Stealth(82);
		player.setSkill_Mecanism(82);
		player.setSkill_Intuition(82);
		player.setSkill_Etheral_Link(82);
		player.setSkill_Object_Knowledge(82);
		player.setSkill_Casting(82);
		player.setSkill_Projectile(82);
		player.setSkill_Close_Combat(82);
		player.setSkill_Defense(82);

		player.setOld_Skill_Stealth(player.getSkill_Stealth());
		player.setOld_Skill_Mecanism(player.getSkill_Mecanism());
		player.setOld_Skill_Intuition(player.getSkill_Intuition());
		player.setOld_Skill_Etheral_Link(player.getSkill_Etheral_Link());
		player.setOld_Skill_Object_Knowledge(player.getSkill_Object_Knowledge());
		player.setOld_Skill_Casting(player.getSkill_Casting());
		player.setOld_Skill_Projectile(player.getSkill_Projectile());
		player.setOld_Skill_Close_Combat(player.getSkill_Close_Combat());
		player.setOld_Skill_Defense(player.getSkill_Defense());

		player.setAttribute_Redistribute((short) 0);
		player.setSkill_Redistribute((short) 0);

		player.setLevel((short) 10);
		player.setXp(178000);
		player.setPoison(0.f);
		player.setHunger(100.f);
		player.setSkin((short) 0);
		// player.setBag((short) 1);

		ARX_PLAYER_ComputePlayerStats(player);
		player.setLife(player.getMaxlife());
		player.setMana(player.getMaxmana());

		player.setRune_flags(0xFFFFFFFF);
		if (player.getSpellToMemorize() != null) {
			player.getSpellToMemorize().setbSpell(false);
		}
	}
	public void ARX_PLAYER_MakeSpHero(final ARXCharacter player) {
		player.setAttribute_Strength(12);
		player.setAttribute_Mind(12);
		player.setAttribute_Dexterity(12);
		player.setAttribute_Constitution(12);

		player.setSkill_Stealth(5);
		player.setSkill_Mecanism(5);
		player.setSkill_Intuition(5);
		player.setSkill_Etheral_Link(5);
		player.setSkill_Object_Knowledge(5);
		player.setSkill_Casting(5);
		player.setSkill_Projectile(5);
		player.setSkill_Close_Combat(5);
		player.setSkill_Defense(5);

		player.setOld_Skill_Stealth(player.getSkill_Stealth());
		player.setOld_Skill_Mecanism(player.getSkill_Mecanism());
		player.setOld_Skill_Intuition(player.getSkill_Intuition());
		player.setOld_Skill_Etheral_Link(player.getSkill_Etheral_Link());
		player.setOld_Skill_Object_Knowledge(player.getSkill_Object_Knowledge());
		player.setOld_Skill_Casting(player.getSkill_Casting());
		player.setOld_Skill_Projectile(player.getSkill_Projectile());
		player.setOld_Skill_Close_Combat(player.getSkill_Close_Combat());
		player.setOld_Skill_Defense(player.getSkill_Defense());

		player.setAttribute_Redistribute((short) 6);
		player.setSkill_Redistribute((short) 10);

		player.setLevel((short) 1);
		player.setXp(0);
		player.setPoison(0.f);
		player.setHunger(100.f);
		player.setSkin((short) 4);
		// player.setBag((short) 1);

		ARX_PLAYER_ComputePlayerStats(player);
		player.setLife(player.getMaxlife());
		player.setMana(player.getMaxmana());

		player.setRune_flags(0xFFFFFFFF);
		if (player.getSpellToMemorize() != null) {
			player.getSpellToMemorize().setbSpell(false);
		}
		SKIN_MOD = 0;
		QUICK_MOD = 0;
	}
	void ARX_PLAYER_ManageTorch() {
		/*
		 * if (CURRENT_TORCH) { CURRENT_TORCH->ignition = 0;
		 * CURRENT_TORCH->durability -= FrameDiff * DIV10000; if
		 * (CURRENT_TORCH->durability <= 0) {
		 * ARX_SPEECH_ReleaseIOSpeech(CURRENT_TORCH); // Need To Kill timers
		 * ARX_SCRIPT_Timer_Clear_By_IO(CURRENT_TORCH); CURRENT_TORCH->show =
		 * SHOW_FLAG_KILLED; CURRENT_TORCH->GameFlags &= ~GFLAG_ISINTREATZONE;
		 * RemoveFromAllInventories(CURRENT_TORCH);
		 * ARX_INTERACTIVE_DestroyDynamicInfo(CURRENT_TORCH);
		 * ARX_SOUND_PlaySFX(SND_TORCH_END); ARX_SOUND_Stop(SND_TORCH_LOOP);
		 * ARX_INTERACTIVE_DestroyIO(CURRENT_TORCH); CURRENT_TORCH = NULL;
		 * SHOW_TORCH = 0; DynLight[0].exist = 0; } }
		 */
	}
	/**
	 * Function to poison player by "val" poison level
	 * @param player
	 * @param val
	 */
	void ARX_PLAYER_Poison(final ARXCharacter player, final float val) {
		// Make a poison saving throw to see if player is affected
		if (Diceroller.getInstance().ARXRnd() * 100.f > player
				.getResist_poison()) {
			player.adjustPoison(val);
			// ARX_SOUND_PlayInterface(SND_PLAYER_POISONED);
		}
	}
	/**
	 * Add quest "quest" to player Questbook.
	 * @param quest
	 * @param _bLoad
	 */
	public void ARX_PLAYER_Quest_Add(final String quest, final boolean _bLoad) {
		if (PlayerQuest == null) {
			PlayerQuest = new ArrayList<STRUCT_QUEST>();
		}
		STRUCT_QUEST sq = new STRUCT_QUEST();
		sq.setIdent(quest);
		sq.setLocalised(quest);
		PlayerQuest.set(nb_PlayerQuest, sq);
		sq = null;
		nb_PlayerQuest++;
		bBookHalo = !_bLoad;// true;
		ulBookHaloTime = 0;
	}
	/** Init/Reset player Quest structures. */
	public void ARX_PLAYER_Quest_Init() {
		if (PlayerQuest != null && PlayerQuest.size() > 0) {
			for (int i = 0; i < nb_PlayerQuest; i++) {
				PlayerQuest.get(i).setIdent(null);
				PlayerQuest.get(i).setLocalised(null);
				PlayerQuest.set(i, null);
			}
			PlayerQuest.clear();
		}

		nb_PlayerQuest = 0;
	}
	/**
	 * Quickgenerate a random hero.
	 * @param player
	 */
	public void ARX_PLAYER_QuickGeneration(final ARXCharacter player) {
		long old_skin = player.getSkin();
		ARX_PLAYER_MakeFreshHero(player);

		old_skin = Common.getInstance().checkCharValue(old_skin);
		player.setSkin((short) old_skin);

		while (player.getAttribute_Redistribute() > 0) {
			float rn = Diceroller.getInstance().ARXRnd();

			if (rn < 0.25f && player.getAttribute_Strength() < 18) {
				player.adjustAttribute_Strength(1);
				player.adjustAttribute_Redistribute((short) -1);
			} else if (rn < 0.5f && player.getAttribute_Mind() < 18) {
				player.adjustAttribute_Mind(1);
				player.adjustAttribute_Redistribute((short) -1);
			} else if (rn < 0.75f && player.getAttribute_Dexterity() < 18) {
				player.adjustAttribute_Dexterity(1);
				player.adjustAttribute_Redistribute((short) -1);
			} else if (player.getAttribute_Constitution() < 18) {
				player.adjustAttribute_Constitution(1);
				player.adjustAttribute_Redistribute((short) -1);
			}
		}

		while (player.getSkill_Redistribute() > 0) {
			float rn = Diceroller.getInstance().ARXRnd();

			if (rn < 0.1f && player.getSkill_Stealth() < 18) {
				player.adjustSkill_Stealth(1);
				player.adjustSkill_Redistribute((short) -1);
			} else if (rn < 0.2f && player.getSkill_Mecanism() < 18) {
				player.adjustSkill_Mecanism(1);
				player.adjustSkill_Redistribute((short) -1);
			} else if (rn < 0.3f && player.getSkill_Intuition() < 18) {
				player.adjustSkill_Intuition(1);
				player.adjustSkill_Redistribute((short) -1);
			} else if (rn < 0.4f && player.getSkill_Etheral_Link() < 18) {
				player.adjustSkill_Etheral_Link(1);
				player.adjustSkill_Redistribute((short) -1);
			} else if (rn < 0.5f && player.getSkill_Object_Knowledge() < 18) {
				player.adjustSkill_Object_Knowledge(1);
				player.adjustSkill_Redistribute((short) -1);
			} else if (rn < 0.6f && player.getSkill_Casting() < 18) {
				player.adjustSkill_Casting(1);
				player.adjustSkill_Redistribute((short) -1);
			} else if (rn < 0.7f && player.getSkill_Projectile() < 18) {
				player.adjustSkill_Projectile(1);
				player.adjustSkill_Redistribute((short) -1);
			} else if (rn < 0.8f && player.getSkill_Close_Combat() < 18) {
				player.adjustSkill_Close_Combat(1);
				player.adjustSkill_Redistribute((short) -1);
			} else if (rn < 0.9f && player.getSkill_Defense() < 18) {
				player.adjustSkill_Defense(1);
				player.adjustSkill_Redistribute((short) -1);
			}
		}

		player.setLevel((short) 0);
		player.setXp(0);
		player.setHunger(100.f);

		ARX_PLAYER_ComputePlayerStats(player);
	}
	/**
	 * Reset all extra-rotation groups of player.
	 * @param player the {@link ARXCharacter}
	 */
	public void ARX_PLAYER_RectifyPosition(final ARXCharacter player) {
		/*
		 * InteractiveObject * io = inter.iobj[0]; if ((io) &&
		 * (io->_npcdata->ex_rotate)) { for (long n = 0; n < MAX_EXTRA_ROTATE;
		 * n++) { io->_npcdata->ex_rotate->group_rotate[n].a = 0;
		 * io->_npcdata->ex_rotate->group_rotate[n].b = 0;
		 * io->_npcdata->ex_rotate->group_rotate[n].g = 0; }
		 * io->_npcdata->ex_rotate->flags = 0; }
		 */
	}
	// Removes player invisibility by killing Invisibility spells on him
	// *************************************************************************************
	/** Removes player invisibility by killing Invisibility spells on him. */
	public void ARX_PLAYER_Remove_Invisibility() {
		for (int i = 0; i < GlobalConsts.MAX_SPELLS; i++) {
			// player is always IO object 0
			if (Spell.getInstance().exists(i)
					&& Spell.getInstance().getType(i) == GlobalConsts.SPELL_INVISIBILITY
					&& Spell.getInstance().getCaster(i) == 0) {
				Spell.getInstance().setTolive(i, 0);
			}
		}
	}
	/**
	 * Add "_ulRune" to player runes.
	 * @param _ulRune the rune being added
	 */
	public void ARX_Player_Rune_Add(final long _ulRune) {
		/*
		 * int iNbSpells = 0; int iNbSpellsAfter = 0; for (long i = 0; i <
		 * SPELL_COUNT; i++) { if (spellicons[i].bSecret == false) { long j = 0;
		 * bool bOk = true; while ((j < 4) && (spellicons[i].symbols[j] != 255))
		 * { if (!(player.rune_flags & (1 << spellicons[i].symbols[j]))) { bOk =
		 * false; } j++; } if (bOk) { iNbSpells ++; } } } player.rune_flags |=
		 * _ulRune; for (int i = 0; i < SPELL_COUNT; i++) { if
		 * (spellicons[i].bSecret == false) { long j = 0; bool bOk = true; while
		 * ((j < 4) && (spellicons[i].symbols[j] != 255)) { if
		 * (!(player.rune_flags & (1 << spellicons[i].symbols[j]))) { bOk =
		 * false; } j++; } if (bOk) { iNbSpellsAfter ++; } } } if
		 * (iNbSpellsAfter > iNbSpells) { MakeBookFX(DANAESIZX -
		 * INTERFACE_RATIO(35), DANAESIZY - INTERFACE_RATIO(148), 0.00001f);
		 * bBookHalo = true; ulBookHaloTime = 0; }
		 */
	}
	/**
	 * Remove "_ulRune" from player runes
	 * @param _ulRune the rune being removed
	 */
	public void ARX_Player_Rune_Remove(final long _ulRune) {
		// player.rune_flags &= ~_ulRune;
	}
	public ARXCharacter getPlayer() {
		return player;
	}
}

class STRUCT_QUEST {
	private String	ident;
	private String	localised;
	public String getIdent() {
		return ident;
	}
	public String getLocalised() {
		return localised;
	}
	public void setIdent(final String val) {
		ident = val;
	}
	public void setLocalised(final String val) {
		localised = val;
	}

}
